Ext.define('cp.view.form.BuscarAdmin',{
    alias: 'widget.buscarAdmin',
    extend: 'Ext.form.Panel',
   
    bodyPadding: '5px 5px 5px 5px', 
    bodyStyle: 'border: none',
    fieldDefaults: {
        labelWidth: 65,
        labelAlign: 'top'
    },
   
    initComponent: function(){
      
       var info = [
            { fieldLabel: 'Nombre', name: 'nombre', vtype: 'letrasEspacios' },
            { fieldLabel: 'Apellido', name: 'apellido', vtype: 'letrasEspacios' },
            { fieldLabel:  'Dni', name: 'dni', vtype: 'identificacion' },
        ];
        
        this.items = [
            {
                bodyStyle: 'border: none',
                layout: 'column',
                itemId: 'columnas',
                items: [
                    {
                        xtype: 'fieldset', defaultType: 'textfield', title: 'Criterios', 
                        layout: 'column', items:
                        [
                            {id:'fieldContainer',xtype: 'fieldset', defaultType: 'textfield', style: 'border: none',
                                items: info}
                        ]
                    }
              ]
            }
         ];  
        
        
        this.callParent(arguments);
    },
    submitForm: function(){
        this.procesarBusqueda();
    },
    procesarBusqueda: function(){
        var me = this;
        var store = Ext.create('cp.store.grid.AdminsFiltrados',{});
        store.load({
           params:{
               nombre: me.getForm().findField('nombre').getSubmitData(),
               apellido: me.getForm().findField('apellido').getSubmitData(),
               dni: me.getForm().findField('dni').getSubmitData()
           },
           callback: function(records, options, success){
                var grid = Ext.ComponentQuery.query('gestionAdmins')[0];
                grid.getView().bindStore(this);
           }
        });
    },
    clearForm: function(){
        var fields = this.getForm().getFields();
        fields.each(function(item){
           item.reset() 
        });
    }
});
